// created by noellynch
// Jun 10, 2009

package com.sceneworker.editors.spatialtransformereditor;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextField;

import net.miginfocom.swing.MigLayout;

import com.myjavautils.swing.MigLayoutUtils;
import com.myjavautils.swing.SwingComponentFactory;
import com.sceneworker.util.swing.timelineeditor.KeyFramesPanel.KeyFramePanelEventListener;

public class NewKeyFramePanel extends JPanel {
	
	public	NewKeyFramePanel(final KeyFramePanelEventListener cl_listener, final JDialog cl_par) {
		setLayout(new MigLayout("inset 5"));
		
		final	JTextField		lcl_time = MigLayoutUtils.numberText(this, "Time", 0.0f, true);
		JButton		lcl_done = SwingComponentFactory.makeAButton("Create");
		lcl_done.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cl_listener.makeNewKeyFrame(Float.parseFloat(lcl_time.getText()));
				cl_par.setVisible(false);
			}
		});
		
		JButton		lcl_cancel = SwingComponentFactory.makeAButton("Cancel");
		lcl_cancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cl_par.setVisible(false);
			}
		});
		
		MigLayoutUtils.makeRightAlignedButtonBar(this, lcl_done, lcl_cancel);
	}
}
